@Echo Off

@SET TwelveHiveDir="c:\program files\common files\microsoft shared\web server extensions\12"
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
@SET MakeCabPath="%WinDir%\System32\MakeCab.exe"

IF %1==Release (Goto PrepareBuildLocation) ELSE (Goto PrepareDebugEnv)

Goto End

:PrepareBuildLocation

REM ***************ListCleanup***********************

REM copy the files required for listcleanup solution
@SET ListCleanupBuildDir=..\..\Build\ListCleanup

Echo Template folder to feature directory
xcopy /e /y 12\* %ListCleanupBuildDir%\12\*

Echo Copy Solution folder 
xcopy /e /y Solution\* %ListCleanupBuildDir%\Solution\*

Echo Copy the Deplysolution and retractsolution batch files
xcopy /y DeploySolution.bat %ListCleanupBuildDir%\
xcopy /y RetractSolution.bat %ListCleanupBuildDir%\

REM ***************ListCleanup***********************

REM store the current directory
Set CurrDir=%cd%

REM ******************Build ListCleanup solution Start********************

REM Navigate to webconfigUI dir to build the solution cab
Cd %ListCleanupBuildDir%
%MakeCabPath% /F Solution\ListCleanup.ddf /D CabinetNameTemplate=ListCleanup.wsp /D DiskDirectory1=..\Drop

REM Copy the deploysolution and retractsolution batch files to drop location
xcopy /y DeploySolution.bat ..\Drop\
xcopy /y RetractSolution.bat ..\Drop\

REM Return to the current dir
Cd %Currdir%

REM Remove the Build\ListCleanup folder
RMDIR /S /Q %ListCleanupBuildDir%

REM ******************Build ListCleanup solution End********************

Goto End

:PrepareDebugEnv

IISReset

Echo 12 hive Template folder to feature directory
xcopy /e /y 12\* %TwelveHiveDir%

Echo Installing feature
%STSADM% -o installfeature -filename  ListCleanupJobFeature\feature.xml -force
%STSADM% -o installfeature -filename  ListCleanupUIFeature\feature.xml -force

Goto End

:End